<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>argument获取非行间样式</title>
		<style>
			#div1{width:200px;background: red;height: 200px;}
		</style>
	</head>
	<body>
		<div id="div1"></div>
		<script>
        function getstyle(obj,name,value){
        	if(arguments.length==2){
        	//判断IE版本
        	if(obj.currentStyle){
        	return obj.currentStyle[name];
        	}else{
        		return getComputedStyle(obj,false)[name];
        	}
        	}else if (arguments.length==3){
        		obj.style[name]=value;
        	}else{
        		alert("输入有误！");
        	}
        }
        //页面加载时执行
			window.onload=function(){
				var div1=document.getElementById("div1");
				alert(getstyle(div1,"width"));
			getstyle(div1,"background","blue");
			}
			
			
		</script>
	</body>
</html>
